﻿using System;
using System.Collections.Generic;

using E.BLL;
using E.Model;
using E.Web.UI.Page;

using X.Common;

namespace E.Web.training.info
{
    public partial class UpdateInfo : BasePage
    {
        public UserModel model;
        public IDictionary<int, string> educationList;

        protected override void ShowPage()
        {
            UserBLL bll = new UserBLL();
            model = bll.GetUserInfoByUserID(userid);
            educationList = bll.GetEducationList();

            if (ispost)
            {
                string username = XRequest.GetString("UserNameTxt");
                string idcard = XRequest.GetString("IDCardTxt");
                string email = XRequest.GetString("EmailTxt");
                //string education = XRequest.GetString("EducationTxt");
                int educationid = XRequest.GetInt("EducationSlt", -1);
                bool gender = XRequest.GetInt("GenderRg", -1) == 1 ? true : false;

                if (username.Equals("") || idcard.Equals(""))
                {
                    ExecuteJS("alert('信息填写错误');");
                }
                else
                {
                    model = new UserModel();
                    model.ID = userid;
                    model.UserName = username;
                    model.IDCard = idcard;
                    model.Email = email;
                    model.Gender = gender;
                    model.EducationID = educationid;

                    int rst = bll.UpdateUserInfo(model);
                    if (rst > 0)
                    {
                        ExecuteJS("alert('更新成功'); window.location = '/training/info/UpdateInfo.aspx';");
                    }
                    else
                    {
                        ExecuteJS("alert('信息填写错误');");
                    }
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}
